<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <script src="../vue.js"></script>
  <title>Document</title>
  <!-- <link rel="stylesheet" href="./reset.css"> -->
  <link rel="stylesheet" href="./css/todolist.css">
  <link rel="stylesheet" href="./css/iconfont/iconfont.css">
  <link rel="stylesheet" href="./swiper/animate.min.css">
  <link rel="stylesheet" href="./swiper/swiper.min.css">

</head>

<body>
  <div id="app">
    <!-- 
        1.有待办事项展示待办事项，没有则显示空空如也
        2.输入内容后，下次输入前应该清除上次的
        3.删除功能
        4.加分项 样式写好看点
       -->



       <!-- 头部 -->
    <div class="head">
      <h1 class="wow animated jello infinite ">todoList(淳陆仁的日常记录)</h1>
      <div class="iconfont icon-zhankai"></div>
    </div>



    <!-- todos部分 -->
    <ul class="todos wow animated bounceInDown">
      <li v-for="(item,index) in list" :key="index">
        <input type="radio">
        {{item}}
        <button class="btn_01" @click="del(index)">你干嘛</button>
      </li>
      <!-- 大量渲染时那就使用v-show 极少数量渲染就使用v-if -->
      <div class="blank" v-show="this.list.length ===0">
        你干嘛~~~哎哟~~~ 啊哈哈 -《鸡哥》
      </div>
    </ul>


    <!-- 尾部搜索部分 -->
    <div class="foot wow animated bounceInDown">
      <div class="inp">
        <input class="in" type="text" v-model="myToDo" placeholder="请输入淳陆仁的日常记录" 
        @keyup.enter="enterHandler()"/>
      </div>
      <div class="btns">
        <button @click="add">Add</button>
      </div>
    </div>

  </div>
  <script src="./swiper/swiper.min.js"></script>
  <script src="./swiper/wow.min.js"></script>
  <script>
    var app = new Vue({
      el: "#app",
      data: {
        myToDo: "",
        list: ["早上七点打篮球", "10点跳最炫民族鸡", "中午看生化危'鸡'","下午唱'鸡你太美'","晚上收听up主道人肖黑子节目"],
      },
      methods: {
        //键盘事件方法
        enterHandler(a){
          if (!this.myToDo) {
            alert("请输入正确的ToDo")
          } else {
            this.list.push(this.myToDo);
          }
          //清空该添加项
          this.myToDo = "";
        },
        //添加待办事项
        add() {
          if (!this.myToDo) {
            alert("请输入正确的ToDo")
          } else {
            this.list.push(this.myToDo);
          }
          //清空该添加项
          this.myToDo = "";
        },
        //删除待办事项
        del(index) {
          console.log(this.list[index]);
          this.list.splice(index, 1)
          // console.log(this.list);
          // this.list = this.list.filter((lis,id) => {
          //   if(this.list[id] !== this.list[index]){
          //     this.list[id] = this.list[index]
          //   }
          //   return this.list
          
          // });
          //为什么过滤不出来呢?

        },


      },
    });
  </script>
</body>

</html>